package com.gnerv.sylvanas.business.manage.logic;

import com.gnerv.sylvanas.framework.common.model.RestResult;
import com.gnerv.sylvanas.framework.core.BaseCurrentAccount;
import com.gnerv.sylvanas.business.manage.model.dto.AccountDetailsDTO;
import com.gnerv.sylvanas.business.manage.model.dto.OrgTreeDTO;
import com.gnerv.sylvanas.business.manage.model.dto.ViewTreeDTO;
import com.gnerv.sylvanas.business.manage.operation.AccountOperationService;
import com.gnerv.sylvanas.business.manage.operation.OrgOperationService;
import com.gnerv.sylvanas.business.manage.operation.ViewOperationService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
@AllArgsConstructor
public class CurrentAccountLogicService  {

    private final BaseCurrentAccount baseCurrentAccount;
    private final AccountOperationService accountOperationService;
    private final ViewOperationService viewOperationService;
    private final OrgOperationService orgOperationService;

    
    public RestResult<AccountDetailsDTO> selectAccountDetails() {
        String ukId = baseCurrentAccount.ukId();
        AccountDetailsDTO accountDetailsDTO = accountOperationService.selectDetailsByUkId(ukId);
        return RestResult.ok(accountDetailsDTO);
    }

    
    public RestResult<List<ViewTreeDTO>> selectListViewTree() {
        String ukId = baseCurrentAccount.ukId();
        List<ViewTreeDTO> viewTreeDTOList = viewOperationService.selectListTreeByAccountUkId(ukId);
        return RestResult.ok(viewTreeDTOList);
    }

    
    public RestResult<List<OrgTreeDTO>> selectListOrgTree() {
        String ukId = baseCurrentAccount.ukId();
        List<OrgTreeDTO> orgTreeDTOList = orgOperationService.selectListTreeByAccountUkId(ukId);
        return RestResult.ok(orgTreeDTOList);
    }

}
